package com.example.mobifin_busticket;

import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;

import com.example.mobifin_busticket.controller.callbacks.ParseListner;
import com.example.mobifin_busticket.controller.networkmanager.NetworkManager;
import com.example.mobifin_busticket.models.BaseRequestEntityForBusTicketSeat;
import com.example.mobifin_busticket.models.RequestEntityBalanceCut;

public class AsyncTaskForMobifin extends
        AsyncTask<String, String, Object> {
    Context mContext;
    private NetworkManager networkManager = NetworkManager.getInstance();
    private RequestEntityBalanceCut baseRequestEntityForBusTicket;
    ParseListner mListner;
    String strTag, pdMessage;
    boolean isShowing = false;

    public AsyncTaskForMobifin(Context mContext,
            RequestEntityBalanceCut baseRequestEntityForBusTicket,
            ParseListner mListner, String tag, String pdMessage) {
        this.baseRequestEntityForBusTicket = baseRequestEntityForBusTicket;
        this.mListner = mListner;
        this.mContext = mContext;
         this.pdMessage = pdMessage;
    }

    

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
         MyApplication.showProgressDialog(mContext, "Please wait..");
//        if (!isShowing && !MyApplication.getPd().isShowing()) {
//            if (pdMessage.contains("-")) {
//                pdTitleMsg = pdMessage.split(",");
//                pdDestinationmsg = pdTitleMsg[1].split("-");
//                MyApplication.showProgressDialog(mContext, pdTitleMsg[0]);
//            } else {
//                pdTitleMsg = pdMessage.split(",");
//                MyApplication.showProgressDialog(mContext, pdTitleMsg[0]);
//            }
//        }
    }

    protected Object doInBackground(String... params) {
        String httpresponse = "";
        httpresponse = networkManager.makeHttpConnectionToSwitch(mContext, baseRequestEntityForBusTicket);
        Log.d("jsonString", "" + httpresponse);
        return mListner.onParse(httpresponse);
    }
}